* read in annual state population data 
* from seer data

clear
set more off

infix  ///
int year 1-4 ///
int fips 7-8 ///
int race 14 ///
int origin 15 ///
int age_grp 17-18 ///
long pop 19-26 ///
using us.1990_2014.19ages.txt
tab race 
tab origin
save seer_pop_dat, replace
gen white=race==1
gen black=race==2
gen other=1-white-black
gen wpop=white*pop
gen bpop=black*pop
gen opop=other*pop
gen hispanic=origin==1
gen hpop=hispanic*pop
gen agele19=age_grp<=4
gen age2034=age_grp>=5 & age_grp<=7
gen age3549=age_grp>=8 & age_grp<=10
gen age5064=age_grp>=11 & age_grp<=13
gen age6579=age_grp>=14 & age_grp<=16
gen agege80=age_grp>=17
gen agele19p=agele19*pop
gen age2034p=age2034*pop
gen age3549p=age3549*pop
gen age5064p=age5064*pop
gen age6579p=age6579*pop
gen agege80p=agege80*pop
sort fips year
collapse (sum) pop wpop bpop opop hpop agele19p age2034p age3549p age5064p age6579p agege80p, by(fips year)
label var pop "population"
rename pop population
rename wpop white_pop
rename bpop black_pop
rename opop other_pop
rename hpop hispanic_pop
rename agele19p agele19_pop
rename age2034p age2034_pop
rename age3549p age3549_pop
rename age5064p age5064_pop
rename age6579p age6579_pop
rename agege80p agege80_pop
label var white_pop "population that is white"
label var black_pop "population that is black"
label var other_pop "population that is other"
label var hispanic_pop "population that is hispanic"
label var agele19_pop "population that is <=19"
label var age2034_pop "population that is 20-34"
label var age3549_pop "population that is 35-49"
label var age5064_pop "population that is 50-64"
label var age6579_pop "population that is 65-79"
label var agege80_pop "population that is >=80"
desc 
sum
save state_pop_annual, replace






